package com.group.project.hrms.service.impl;

import com.group.project.hrms.entity.SystemAdminInfo;
import com.group.project.hrms.mapper.SystemAdminInfoMapper;
import com.group.project.hrms.service.ISystemAdminInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

@Service
public class SystemAdminInfoService implements ISystemAdminInfoService {

    @Autowired
    private SystemAdminInfoMapper systemAdminInfoMapper;

    @Override
    public int insertSystemAdminInfo(SystemAdminInfo systemAdminInfo) {
        return systemAdminInfoMapper.insert(systemAdminInfo);
    }

    @Override
    public int deleteSystemAdminInfo(SystemAdminInfo systemAdminInfo) {
        return systemAdminInfoMapper.deleteByPrimaryKey(systemAdminInfo);
    }

    @Override
    public int updateSystemAdminInfo(SystemAdminInfo systemAdminInfo) {
        return systemAdminInfoMapper.updateByPrimaryKey(systemAdminInfo);
    }

    @Override
    public SystemAdminInfo selectOneSystemAdminInfo(SystemAdminInfo systemAdminInfo) {
        return systemAdminInfoMapper.selectByPrimaryKey(systemAdminInfo);
    }

    @Override
    public SystemAdminInfo selectSystemAdminInfoByAdminID(String aid) {
        Example example = new Example(SystemAdminInfo.class);
        Example.Criteria criteria = example.createCriteria();
        criteria.orEqualTo("userId" , aid);
        return systemAdminInfoMapper.selectOneByExample(example);
    }

    @Override
    public List<SystemAdminInfo> selectAllSystemAdminInfo() {
        return systemAdminInfoMapper.selectAll();
    }
}
